Skip Headers

Oracle® Database PL/SQL User's Guide and Reference 10g Release 2 (10.2) Part Number B14261-01 |
Home | Book List | Contents | Index | Master Index | Feedback

Previous | Next
| View PDF

# EXCEPTION_INIT Pragma

The pragma `EXCEPTION_INIT` associates an exception name with an Oracle error number. You can intercept any ORA- error and write a specific handler for it instead of using the `OTHERS` handler. For more information, see "Associating a PL/SQL Exception with a Number: Pragma EXCEPTION_INIT".

Syntax

exception_init pragma ::=

Description of the illustration exception_init_pragma.gif

Keyword and Parameter Description

error_number

Any valid Oracle error number. These are the same error numbers (always negative) returned by the function `SQLCODE`.

exception_name

A user-defined exception declared within the current scope.

PRAGMA

Signifies that the statement is a compiler directive.

Usage Notes

You can use `EXCEPTION_INIT` in the declarative part of any PL/SQL block, subprogram, or package. The pragma must appear in the same declarative part as its associated exception, somewhere after the exception declaration.

Be sure to assign only one exception name to an error number.

Examples

For examples, see the following:

Example 10-4, "Using PRAGMA EXCEPTION_INIT"
Example 11-9, "Bulk Operation That Continues Despite Exceptions"

Related Topics

"AUTONOMOUS_TRANSACTION Pragma"
"Exception Definition"
"SQLCODE Function"